<!--修改登录方式-->
<template>
    <a-modal v-model="showUKeyAuth"  :width="840"
             title="修改登录方式"
             :maskClosable="false" :footer="null"
             :destroyOnClose="true">
        <div style="margin: 10px auto 20px; width: 900px; padding-bottom: 60px">
            <a-steps class="steps" :current="current" style="margin-bottom:50px; width: 100%">
                <a-step title="验证已有登录方式" />
                <a-step title="选择登录方式" />
                <a-step title="完成" />
            </a-steps>
            <a-form :form="form" v-if="current === 0">
                <a-form-item style="margin-top: 40px;margin-bottom: 0 !important; ">
                    <a-input
                            :disabled="btnLoading"
                            placeholder="请输入用户名"
                            size="large" disabled
                            autocomplete="off"
                            v-decorator="[
                                'userName',
                                {
                                    rules: [{ required: true, message: '请输入用户名' }],
                                    getValueFromEvent: event => {
                                        return this.verify.formalSpace(event)
                                    }
                                }
                            ]"
                    >
                        <em slot="prefix" class="coin name"/>
                    </a-input>
                </a-form-item>
                <a-form-item v-if="pwdType !== '0'">
                    <a-input
                            :disabled="btnLoading"
                            type="password"
                            size="large"
                            placeholder="请输入密码"
                            @pressEnter="allSubmit"
                            autocomplete="off"
                            style="color: #1f2f40;-webkit-text-security:disc; text-security:disc;ime-mode: disabled;"
                            onpaste="return false"
                            oncopy="return false"
                            oncut="return false"
                            @focus="changePwd"
                            @blur="changePwd"
                            @change="changePwd"
                            v-decorator="[
                                'password',
                                {
                                    rules: [{ required: true, message: '请输入密码' }],
                                    getValueFromEvent: event => {
                                        return this.verify.formalSpace(event)
                                    }
                                }
                            ]"
                    >
                        <em slot="prefix" class="coin msg"/>
                    </a-input>
                </a-form-item>
                <template v-if="pwdType === '0'">
                    <a-form-item style=" margin-bottom: 8px !important; ">
                        <a-input
                                v-model="baseForm.deviceId"
                                placeholder="设备序列号"
                                size="large"
                                autocomplete="off"
                                disabled
                        >
                            <em slot="prefix" class="coin uukey"/>
                        </a-input>
                    </a-form-item>
                    <a-form-item>
                        <a-input
                                :disabled="btnLoading"
                                size="large"
                                placeholder="请输入PIN码"
                                @pressEnter="submitUKeyLogon"
                                autocomplete="off"
                                style="color: #1f2f40;-webkit-text-security:disc; text-security:disc;ime-mode: disabled;"
                                type="password" ref="refocus1" v-model="baseForm.passwd"
                                @change="encodePsw"
                        >
                            <em slot="prefix" class="coin msg"/>
                        </a-input>
                    </a-form-item>
                </template>
                <a-form-item style=" margin-bottom: 8px !important; ">
                    <a-input
                            v-model="baseForm.deviceId"
                            placeholder="设备序列号"
                            size="large"
                            autocomplete="off"
                            disabled
                    >
                        <em slot="prefix" class="coin uukey"/>
                    </a-input>
                </a-form-item>
                <a-form-item>
                    <a-input
                            :disabled="btnLoading"
                            size="large"
                            placeholder="请输入PIN码"
                            @pressEnter="submitUKeyLogon"
                            autocomplete="off"
                            style="color: #1f2f40;-webkit-text-security:disc; text-security:disc;ime-mode: disabled;"
                            type="password" v-model="baseForm.passwd"
                            @change="encodePsw"
                    >
                        <em slot="prefix" class="coin msg"/>
                    </a-input>
                </a-form-item>
                <a-form-item label=" " v-bind="formStyle" class="noLabelAfter">
                    <a-button type="primary" @click="verifyPinCode">确定</a-button>
                </a-form-item>
            </a-form>
            <a-form :form="form" v-if="current === 1">
                <a-form-item label="用户名：" v-bind="formStyle" style="margin-top: 40px;margin-bottom: 0 !important; ">
                    <a-input
                            :disabled="btnLoading"
                            placeholder="请输入用户名"
                            size="large" disabled
                            autocomplete="off"
                            v-decorator="[
                                'userName',
                                {
                                    rules: [{ required: true, message: '请输入用户名' }],
                                    getValueFromEvent: event => {
                                        return this.verify.formalSpace(event)
                                    }
                                }
                            ]"
                    >
                        <em slot="prefix" class="coin name"/>
                    </a-input>
                </a-form-item>
                <a-form-item label="访问方式：" style=" margin-bottom: 0 !important; height: 50px !important;">
                    <a-radio-group  v-decorator="['pwdType', { initialValue: '1' }]">
                        <a-radio value="1">密码</a-radio>
                        <a-radio value="0">UKey</a-radio>
                    </a-radio-group>
                </a-form-item>
                <a-form-item v-if="form.getFieldValue('pwdType') !== '0'">
                    <a-input
                            :disabled="btnLoading"
                            type="password"
                            size="large"
                            placeholder="请输入密码"
                            @pressEnter="allSubmit"
                            autocomplete="off"
                            style="color: #1f2f40;-webkit-text-security:disc; text-security:disc;ime-mode: disabled;"
                            onpaste="return false"
                            oncopy="return false"
                            oncut="return false"
                            @focus="changePwd"
                            @blur="changePwd"
                            @change="changePwd"
                            v-decorator="[
                                'password',
                                {
                                    rules: [{ required: true, message: '请输入密码' }],
                                    getValueFromEvent: event => {
                                        return this.verify.formalSpace(event)
                                    }
                                }
                            ]"
                    >
                        <em slot="prefix" class="coin msg"/>
                    </a-input>
                </a-form-item>
                <template v-if="form.getFieldValue('pwdType') === '0'">
                    <a-form-item style=" margin-bottom: 8px !important; ">
                        <a-input
                                v-model="baseForm.deviceId"
                                placeholder="设备序列号"
                                size="large"
                                autocomplete="off"
                                disabled
                        >
                            <em slot="prefix" class="coin uukey"/>
                        </a-input>
                    </a-form-item>
                    <a-form-item>
                        <a-input
                                :disabled="btnLoading"
                                size="large"
                                placeholder="请输入PIN码"
                                @pressEnter="submitUKeyLogon"
                                autocomplete="off"
                                style="color: #1f2f40;-webkit-text-security:disc; text-security:disc;ime-mode: disabled;"
                                type="password" ref="refocus1" v-model="baseForm.passwd"
                                @change="encodePsw"
                        >
                            <em slot="prefix" class="coin msg"/>
                        </a-input>
                    </a-form-item>
                </template>
                <a-form-item label="请选择UKEY：" v-bind="formStyle">
                    <a-select style="width: 350px" @change="changeLabel"
                              placeholder="全部" v-model="selectUkey.deviceId">
                        <a-select-option v-for="item in dmkNumList" :value="item.value"
                                         :key="item.value">{{item.label }}
                        </a-select-option>
                    </a-select>
                </a-form-item>
                <a-form-item label="请输入PIN码：" v-bind="formStyle" :extra="msg">
                    <a-input placeholder="请输入PIN码" type="password" v-model="selectUkey.pinCode"
                             @change="validePassword(selectUkey.pinCode,'msg')" style="width: 350px"></a-input>
                </a-form-item>
                <a-form-item label=" " v-bind="formStyle" class="noLabelAfter">
                    <a-button type="primary" @click="verifyPinCode">下一步</a-button>
                </a-form-item>
            </a-form>
        </div>
    </a-modal>
</template>
<script>
    const Base64 = require ('js-base64').Base64
    import * as State from '@/libs/baseStateConts'

    export default {
        name: 'pwdAndKey',
        data () {
            /**
             * UKEY设备PIN码验证（6个数值型字符）
             */
            const validePinCode = ( rule, value, callback ) => {
                if (!value || value.trim ().length === 0) {
                    callback (new Error ('安全UKey登录密码不能为空'))
                } else if (value.trim ().length < 6 || value.trim ().length > 16) {
                    callback (new Error ('请输入6-16密码'))
                } else {
                    callback ()
                }
            }

            return {
                pwdType:0,
                showUKeyAuth: false,
                form: this.$form.createForm(this),
                formStyle: {
                    labelCol: { span: 6 },
                    wrapperCol: { span: 17 }
                },
                current:0,
                //授权表单
                uKeyDevFrom: {
                    id: '',
                    userName: '',
                    password: '',
                    roleType: '',
                    name: '',
                    sfzjh: '',
                    serialNum: '',
                    pinCode: ''
                },

                isUKeyLogin: false,
                showLoadUrl: false,
                scanUKeyTimer: -1,
                msg: '',

                //授权表单控制
                authCtlflag: {
                    loginBtnCtl: true,
                    authBtnCtl: true
                },
                options1: [
                    {
                        value: '1',
                        label: '系统管理员'
                    },
                    {
                        value: '2',
                        label: '普通操作员'
                    }
                ],
                timer: '',
                getUkeyCount: 0,
                isFirst: true,
                oldDeviceId: sessionStorage.getItem ('deviceId'),
                nullMsg: '',
                isProtectiveUser:false,
                isForm:'',
                baseForm: {
                    userName: '',
                    password: '',
                    user: '',
                    passwd: '',
                    deviceId: '',
                    deviceId2: '',
                    passwd2: '',
                    passwd3: ''
                },
                btnLoading:false,
            }
        },

        computed: {},

        methods: {
            encodePsw() {
                this.encodedPsw = encodeURIComponent(this.baseForm.passwd)
            },
            validePassword(value,type){
                this[type] = ''
                if (!value || value.trim ().length === 0) {
                    this[type] = '安全UKey登录密码不能为空'
                } else if (value.trim ().length < 6 || value.trim ().length > 16) {
                    this[type] = '请输入6-16位安全UKey登录密码'
                }
            },

            /**
             * 开启扫描UKey设备定时器
             */
            startScanTimer () {
                let _this = this
                _this.clearScanTimer ()
                //开启扫描外接密钥存储设备定时器
                _this.timer = setInterval (function () {
                    _this.updDevSerialNum ()
                }, 1000 * 1)
            },

            /**
             * 更新UKey设备序列号
             */
            updDevSerialNum () {
                let _this = this
                let getAuthDevUri = '/ukeyauth/getDeviceSerialNum'
                if (!_this.isProtectiveUser && _this.isFrom === 'user')  {
                    getAuthDevUri = '/ukeyauth/getAuthDevSerialNum'
                    _this.$axios.get (this.$uurl + getAuthDevUri).then (response => {
                        let respData = response.data
                        _this.showLoadUrl = false
                        if (respData.code > 0 || respData.data === '') {

                            _this.uKeyDevFrom.serialNum = ''
                            _this.uKeyDevFrom.pinCode = ''

                            _this.authCtlflag.loginBtnCtl = true
                            _this.authCtlflag.authBtnCtl = true

                            _this.nullMsg = respData.message
                            return
                        }

                        if (_this.uKeyDevFrom.serialNum !== respData.data) {
                            _this.uKeyDevFrom.pinCode = ''
                            _this.uKeyDevFrom.serialNum = respData.data
                            _this.nullMsg = ''
                            _this.authCtlflag.authBtnCtl = true
                            _this.authCtlflag.loginBtnCtl = false
                            return
                        }
                    }).catch (e => {
                        _this.clearScanTimer ()
                        _this.showLoadUrl = true
                    })
                }else{
                    _this.$axios.get (this.$uurl + getAuthDevUri).then (response => {
                        let respData = response.data
                        _this.showLoadUrl = false
                        if (respData.code !== 0 || respData.data === '') {
                            _this.uKeyDevFrom.serialNum = ''
                            _this.uKeyDevFrom.pinCode = ''
                            _this.getUkeyCount++
                            _this.authCtlflag.loginBtnCtl = true
                            _this.authCtlflag.authBtnCtl = true
                            if (_this.getUkeyCount > 30) {
                                _this.clearScanTimer ()
                                //退出UKEY的验证登录
                                _this.$get (this.$uurl + '/ukeyauth/logoutDev')
                                _this.$store.commit ('clearOpenedSubmenu')
                                _this.$store.commit ('logout', this)
                                _this.$notification.warning ({
                                    message: respData.message + '，请重新登陆'
                                })
                                //延时2s返回登录页
                                setTimeout (function () {
                                    _this.$router.push ({
                                        name: 'login'
                                    })
                                }, 3 * 1000)
                                window.location.reload ()
                            }
                            _this.nullMsg = respData.message
                            return
                        }

                        if (_this.oldDeviceId !== null && _this.oldDeviceId !== undefined && _this.oldDeviceId !== respData.data) {
                            _this.clearScanTimer ()
                            //退出UKEY的验证登录
                            _this.$get (this.$uurl + '/ukeyauth/logoutDev')
                            _this.$store.commit ('clearOpenedSubmenu')
                            _this.$store.commit ('logout', this)
                            sessionStorage.setItem ('interceptorMsg', 'UKey授权不一致，请重新登陆')
                            //延时2s返回登录页
                            setTimeout (function () {
                                _this.$router.push ({
                                    name: 'login'
                                })
                            }, 3 * 1000)
                            window.location.reload ()
                        }
                        if (_this.uKeyDevFrom.serialNum !== respData.data) {
                            _this.uKeyDevFrom.pinCode = ''
                            _this.uKeyDevFrom.serialNum = respData.data
                            _this.nullMsg = ''
                            _this.authCtlflag.authBtnCtl = true
                            _this.authCtlflag.loginBtnCtl = false
                        }
                    }).catch (e => {
                        _this.clearScanTimer ()
                        _this.showLoadUrl = true
                    })
                }
            },

            /**
             * 关闭扫描UKey设备定时器
             */
            clearScanTimer () {
                let _this = this
                if (_this.timer !== null) {
                    clearInterval (_this.timer)
                    _this.timer = null
                }
            },

            /**
             * Function    : downLoadUkeyDevice
             * Description : 下载U盾认证登录驱动
             * a-input       : None
             * Return      : None
             */
            downLoadUkeyDevice () {
                document.getElementById ('ifile').src = State.downloadUKeyAuthTool
            },

            /**
             * Function    : logonDev
             * Description : UKey设备PIN码验证登录
             * a-input       : rowData 操作行记录信息
             * Return      : None
             */
            logonDev ( fromName ) {
                let _this = this
                if((_this.msg === '' || _this.msg === null) && _this.uKeyDevFrom.serialNum !== ''){
                    /**
                     * UKey设备PIN码验证登录
                     */
                    _this.msg = ''
                    let params = {pinCode: Base64.encode (_this.uKeyDevFrom.pinCode)}
                    let skLoginDevUri = '/ukeyauth/skLoginDev'
                    if (!_this.isProtectiveUser && _this.isFrom === 'user')  {
                        skLoginDevUri = '/ukeyauth/skLoginAuthDev';
                    }
                    this.$axios.get (this.$uurl + skLoginDevUri, {params: params}).then (response => {
                        let respData = response.data
                        if (respData.code !== 0) {
                            _this.msg = respData.message
                            return
                        }
                        //修改授权按钮状态
                        _this.authCtlflag.authBtnCtl = false
                        _this.authCtlflag.loginBtnCtl = true
                        _this.$message.success ('安全UKey验证登录成功')
                        // _this.checkAndInitAuthUKey('uKeyDevFrom');
                    }).catch (e => {
                        _this.msg = '调用UKey端登录接口失败'
                    })
                }
            },

            /**
             * Function    : checkAndAuthUKey
             * Description : 验证授权设备并且UKey授权
             * a-input       : fromName 授权表单信息
             * Return      : None
             */
            checkAndInitAuthUKey ( fromName ) {
                let _this = this
                _this.authCtlflag.authBtnCtl = true
                if(_this.isFrom === 'user'){
                    let params = {isFristAuthUKey: _this.isProtectiveUser}
                    _this.$axios.get(_this.$uurl + '/ukeyauth/existsSymmetryKeys', {params: params}).then(response => {
                        let respData = response.data;
                        if (respData.code !== 0)  {
                            _this.authCtlflag.authBtnCtl = false;
                            _this.$message.error(respData.message);
                            return;
                        }

                        if(respData.data) {
                            //已授权设备初始化处理
                            _this.handleInitAuthDev (fromName);
                        } else {
                            //执行UKey与用户授权
                            _this.uKeyAuth(fromName);
                        }
                        _this.authCtlflag.authBtnCtl = false;
                    }).catch( e => {
                        _this.authCtlflag.authBtnCtl = false;
                    });
                }else{
                    let params = {isFristAuthUKey: true}
                    _this.$axios.get (this.$uurl + '/ukeyauth/existsSymmetryKeys', {params: params}).then (response => {
                        let respData = response.data
                        if (respData.code !== 0) {
                            _this.$message.error (respData.message)
                            _this.authCtlflag.authBtnCtl = false
                            return
                        }
                        if (respData.code === 0 && respData.data === true) {
                            this.$confirm ({
                                title: `UKey存在授权信息，确定重置吗？`,
                                onOk: () => {
                                    params = Object.assign ({}, {authType: State.LOGIC_NUM_TRUE})
                                    _this.$axios.post (this.$uurl + '/authmanager/resetUserUKeyAuthInfo', params, {}).then (res => {
                                        let resps = res.data
                                        if (resps.code === 0) {
                                            _this.uKeyAuth (fromName)
                                        } else {
                                            _this.$message.error (res.message)
                                        }
                                    })
                                },
                                onCancel: () => {
                                }
                            })
                        } else {
                            _this.uKeyAuth (fromName)
                        }
                        _this.authCtlflag.authBtnCtl = false
                    }).catch (e => {
                        _this.authCtlflag.authBtnCtl = false
                    })
                }
            },
            /**
             * Function    : handleInitAuthDev
             * Description : 已授权设备初始化处理
             * Input       : fromName 授权表单信息
             * Return      : None
             */
            handleInitAuthDev(fromName) {
                /**
                 * 获取授权设备的系统用户信息
                 */
                let _this = this;
                let authType = _this.isProtectiveUser ? State.LOGIC_NUM_TRUE : State.LOGIC_NUM_FALSE;
                let params = Object.assign({}, {authType: authType});
                _this.$axios.post(_this.$uurl + '/authmanager/loadUserUKeyAuthInfo', params, {}).then(response => {
                    let respData = response.data;
                    if (respData.code !== 0) {
                        _this.$message.error(respData.message);
                        return;
                    }

                    /**
                     * 验证服务端的授权情况
                     */
                    params = Object.assign({}, respData.data);
                    this.$store.dispatch('getUserAuthUKeyAct', params).then(response => {
                        if (response.code !== 0) {
                            _this.$message.error(response.message);
                            return;
                        }

                        //设备内存储与后台系统存在授权信息
                        let data = response.data;
                        if (data.authStatus === State.LOGIC_NUM_TRUE) {
                            _this.$message.error('UKey已授权系统用户“' + respData.data.userName + '”，请更换新的UKey');
                        } else {
                            this.$confirm({
                                title: 'UKey存在系统用户“' + respData.data.userName + '”授权信息，确定重置吗？',
                                onOk: () => {
                                    /**
                                     * 系统已经解绑，则重置UKey授权信息
                                     */
                                    params = Object.assign({}, {authType: authType});
                                    _this.$axios.post(this.$uurl + '/authmanager/resetUserUKeyAuthInfo', params, {}).then(response => {
                                        let respData = response.data;
                                        if (respData.code === 0) {
                                            //执行UKey与用户授权
                                            _this.uKeyAuth(fromName);
                                        } else {
                                            this.$message.error(respData.message);
                                        }
                                    });
                                },
                                onCancel: () => {
                                }
                            });

                        }
                    });
                });
            },

            /**
             * Function    : uKeyAuth
             * Description : UKey授权
             * a-input       : fromName 授权表单信息
             * Return      : None
             */
            uKeyAuth ( fromName ) {
                let _this = this
                let authType = State.LOGIC_NUM_TRUE
                let params = {
                    userName: _this.uKeyDevFrom.userName,
                    authType: authType
                }
                if(_this.isFrom === 'user'){
                    authType = _this.isProtectiveUser ? State.LOGIC_NUM_TRUE : State.LOGIC_NUM_FALSE;
                    params = {
                        userName:_this.uKeyDevFrom.userName,
                        authType:authType
                    };
                }

                _this.authCtlflag.authBtnCtl = true
                /**
                 * 生成授权请求参数
                 */
                _this.$axios.post (this.$uurl + '/authmanager/ganRequestAuthParams', params, {}).then (response => {
                    let respData = response.data
                    if (respData.code !== 0) {
                        _this.authCtlflag.authBtnCtl = false
                        _this.$message.error (respData.message)
                        return
                    }

                    /**
                     * 生成授权信息，并服务存储
                     */
                    params = Object.assign ({}, respData.data)
                    this.$store.dispatch ('makeAuthUKeyToUserAct', params).then (response => {
                        if (response.code !== 0) {
                            _this.authCtlflag.authBtnCtl = false
                            /**
                             * UKEY绑定系统用户失败，则删除初始化的授权容器
                             */
                            params = Object.assign ({}, {authType: authType})
                            _this.$axios.post (this.$uurl + '/authmanager/resetUserUKeyAuthInfo', params, {})
                            _this.$message.error (response.message)
                        } else {
                            /**
                             * 授权认证信息写入UKey
                             */
                            params = Object.assign ({}, response.data)
                            _this.$axios.post (this.$uurl + '/authmanager/saveUserUKeyAuthInfo', params, {}).then (response => {
                                let respData = response.data
                                if (respData.code !== 0) {
                                    //生成撤销授权参数
                                    params = Object.assign ({}, {
                                        userName: _this.uKeyDevFrom.userName,
                                        authType: authType
                                    })
                                    _this.$axios.post (this.$uurl + '/authmanager/ganCancelAuthInfoParams', params, {}).then (response => {
                                        let respData = response.data
                                        if (respData.code === 0) {
                                            //请求撤销本次授权
                                            _this.$store.dispatch ('cancelUserAuthUKeyAct', respData)
                                        }
                                    }).catch (e => {
                                    })

                                    _this.authCtlflag.authBtnCtl = false
                                    _this.$message.error ('写入安全UKey授权信息失败')
                                    return
                                }
                                if(_this.isFrom === 'user'){
                                    /**
                                     * 自动关闭授权对话框
                                     */
                                    _this.showUKeyAuth = false
                                    _this.uKeyDevFrom={
                                        id: '',
                                        userName: '',
                                        password: '',
                                        roleType: '',
                                        name: '',
                                        sfzjh: '',
                                        serialNum: '',
                                        pinCode: ''
                                    }
                                    /**
                                     * 初始化表单操作按钮状态
                                     */
                                    _this.authCtlflag.authBtnCtl = true
                                    _this.authCtlflag.loginBtnCtl = true

                                    //关闭扫描外接UKey设备定时器
                                    _this.clearScanTimer ()
                                    _this.isProtectiveUser = false
                                    _this.$emit('init')
                                    _this.isFrom = ''
                                    this.$message.success (respData.message)
                                }else{
                                    _this.isFrom = ''
                                    /**
                                     * 自动关闭授权对话框
                                     */
                                    //关闭扫描外接UKey设备定时器
                                    _this.clearScanTimer ()

                                    //清空表单信息
                                    _this.uKeyDevFrom={
                                        id: '',
                                        userName: '',
                                        password: '',
                                        roleType: '',
                                        name: '',
                                        sfzjh: '',
                                        serialNum: '',
                                        pinCode: ''
                                    }

                                    _this.showUKeyAuth = false
                                    sessionStorage.clear ()

                                    _this.$get (this.$uurl + '/ukeyauth/logoutDev')
                                    sessionStorage.setItem ('interceptorMsg', '系统默认管理员UKey授权成功，请重新登录')
                                    //延时2s返回登录页
                                    setTimeout (function () {
                                        _this.$router.push ({
                                            name: 'login'
                                        })
                                    }, 2 * 1000)
                                    window.location.reload ()
                                }
                            }).catch (e => {
                            })
                        }

                    })

                }).catch (e => {
                })
            },

            /**
             * Function    : cancelAuthUKey
             * Description : 取消授权操作
             * a-input       : fromName 授权表单信息
             * Return      : None
             */
            cancelAuthUKey ( fromName ) {
                let _this = this
                _this.$get (this.$uurl + '/ukeyauth/logoutDev')
                _this.$store.commit ('clearOpenedSubmenu')
                _this.showUKeyAuth = false

                sessionStorage.clear ()

                //清空表单信息
                _this.uKeyDevFrom={
                    id: '',
                      userName: '',
                      password: '',
                      roleType: '',
                      name: '',
                      sfzjh: '',
                      serialNum: '',
                      pinCode: ''
                }

                /**
                 * 初始化表单操作按钮状态
                 */
                _this.authCtlflag.authBtnCtl = true
                _this.authCtlflag.loginBtnCtl = true

                //关闭扫描外接UKey设备定时器
                _this.clearScanTimer ()
                //延时2s返回登录页
                setTimeout (function () {
                    _this.$router.push ({
                        name: 'login'
                    })
                }, 3 * 1000)
                window.location.reload ()
            },

            showModal (isFrom) {
                let _this = this
                this.isFrom = isFrom
                //系统是否开启UKey身份鉴别登录
                _this.$store.dispatch ('loadProtectiveSysUserAct').then (response => {
                    if (response.code === 0) {
                        let data = response.data
                        //赋值表单数据
                        _this.uKeyDevFrom = Object.assign ({}, {
                            id: data.id,
                            userName: data.userName,
                            roleType: data.roleType,
                            name: data.name,
                            sfzjh: data.sfzjh,
                            serialNum: '',
                            pinCode: ''
                        })

                        //初始化页面按钮、可编辑表单输入框状态
                        _this.authCtlflag.authBtnCtl = true
                        _this.authCtlflag.loginBtnCtl = true
                        _this.msg = ''
                        _this.startScanTimer ()
                    }
                })
                _this.showUKeyAuth = true
            },
            showUserModal (rowData,isFrom) {
                let _this = this
                this.isFrom = isFrom
                //表单初始化赋值
                _this.uKeyDevFrom = Object.assign({},_this.uKeyDevFrom, rowData);

                /**
                 * 是否是针对系统默认用户授权
                 */
                _this.isProtectiveUser = '1' === rowData.protective;

                //初始化页面按钮、可编辑表单输入框状态
                _this.authCtlflag.authBtnCtl =true;
                _this.authCtlflag.loginBtnCtl =true;
                _this.showUKeyAuth = true;
                _this.msg ='';
                _this.nullMsg ='';
                _this.showUKeyAuth ='';
                _this.startScanTimer();
                _this.showUKeyAuth = true
            },
        }
    }
</script>
<style lang="less" scoped>

</style>
